﻿using System;
using System.Windows.Forms;
using log4net;
using Protobuf_Gui.Controls;
using Protobuf_Gui.Domain;

namespace Protobuf_Gui
{
    public class MahApp
    {
        private readonly ILog _log = LogManager.GetLogger("Console");

        private readonly IMain _main;

        public MahApp(IMain main)
        {
            _main = main;
            _main.BeginExit += MainBeginExit;
            _main.BeginNew += MainBeginNew;
            _main.BeginOpen += MainBeginOpen;
            _main.BeginSave += MainBeginSave;
            _main.ShowAbout += MainShowAbout;
            _main.NodeSelected += MainNodeSelected;
            _main.DoOperation += MainDoOperation;
        }

        void MainDoOperation(Operation operation)
        {
            switch (operation)
            {
                case Operation.Delete:
                    BeginDelete();
                    break;
                case Operation.Insert:
                    BeginInsert();
                    break;
            }
        }

        void MainNodeSelected(TreeNode node)
        {
            
        }
        
        private void BeginDelete()
        {
            _log.Info("MahApp BeginDelete");
        }

        private void BeginInsert()
        {
            _log.Info("MahApp BeginInsert");
        }

        void MainShowAbout(object sender, EventArgs e)
        {
            
        }

        void MainBeginSave(object sender, EventArgs e)
        {
            
        }

        void MainBeginOpen(object sender, EventArgs e)
        {
            
        }

        void MainBeginNew(object sender, EventArgs e)
        {
            
        }

        void MainBeginExit(object sender, EventArgs e)
        {
        }

        public void Run()
        {
            Application.Run(_main.AsForm);
        }
    }
}